package com.blog.wl2023.controller.admin;

import com.blog.wl2023.entity.*;
import com.blog.wl2023.entity.LoadClass.*;
import com.blog.wl2023.entity.response.Result;
import com.blog.wl2023.service.admin.UpdateService;
import com.blog.wl2023.utils.note.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wule
 * @desc
 */
@RestController
@RequestMapping("api/admin/update")
@ResponseResult
public class AdminUpdateController {

	@Autowired
	UpdateService updateService;

	/**
	 * 编辑关于页面:对关于页面,应该永远都是更新而不是添加
	 *
	 * @param article 文章内容
	 * @return ok
	 */
	@PostMapping("updateAbout")
	public Result updateAbout(@RequestBody Article article) {
		return updateService.updateAbout(article);
	}

	/**
	 *更新文章'是否置顶'属性的值
	 * @param article 传递 uuid,isTop
	 * @return Result.ok()
	 */
	@PostMapping("updateArticleIsTop")
	public Result updateArticleIsTop(@RequestBody Article article) {
		return updateService.updateArticleIsTop(article);
	}

	/**
	 *更新文章'是否删除'属性的值
	 * @param article 传递 uuid,isDelete
	 * @return Result.ok()
	 */
	@PostMapping("updateArticleIsDelete")
	public Result updateArticleIsDelete(@RequestBody Article article) {
		return updateService.updateArticleIsDelete(article);
	}

	/**
	 * 批量更新文章'是否删除'属性的值
	 * @param articles  载荷类  每个article 传递 uuid,isDelete
	 * @return Result.ok()
	 */
	@PostMapping("updateArticlesIsDelete")
	public Result updateArticlesIsDelete(@RequestBody ArticlePayload articles) {
		return updateService.updateArticlesIsDelete(articles.getArticles());
	}

	/**
	 * 更新 文章信息 即
	 * @param article 更新信息
	 * @return
	 *     uuid:"",
	 *     title: "",
	 *     summary: "",
	 *     content: "",
	 *     typeId: "",
	 *     author: "",
	 *     quoteLink :"",
	 *     imageUrl: "",
	 *     keyOne: "",
	 */
	@PostMapping("updateArticle")
	public Result updateArticle(@RequestBody Article article) {
		return updateService.updateArticle(article);
	}


	/**
	 *更新随想的'是否删除'属性的值
	 * @param caprice 传递 uuid,isDelete
	 * @return Result.ok()
	 */
	@PostMapping("updateCapriceIsDelete")
	public Result updateCapriceIsDelete(@RequestBody Caprice caprice) {
		return updateService.updateCapriceIsDelete(caprice);
	}

	/**
	 * 批量更新随想的'是否删除'属性的值
	 * @param caprices  载荷类  每个 Caprice 传递 uuid,isDelete
	 * @return Result.ok()
	 */
	@PostMapping("updateCapricesIsDelete")
	public Result updateCapricesIsDelete(@RequestBody CapricePayload caprices) {
		return updateService.updateCapricesIsDelete(caprices.getCaprice());
	}

	/**
	 * 更新 随想信息 即
	 * @param caprice 更新信息
	 * @return
	 *     uuid:"",
	 *     capriceContent:""
	 */
	@PostMapping("updateCaprice")
	public Result updateCaprice(@RequestBody Caprice caprice) {
		return updateService.updateCaprice(caprice);
	}


	/**
	 * 更新 类型信息 即
	 * @param type 更新信息:uuid,typeName, typeInfo, keyOne
	 * @return Result.ok()
	 */
	@PostMapping("updateType")
	public Result updateType(@RequestBody Type type) {
		return updateService.updateType(type);
	}

	/**
	 * 批量删除类型
	 * @param types 类型list
	 * @return Result
	 */
	@PostMapping("deleteTypes")
	public Result deleteTypes(@RequestBody TypePayload types) {
		return updateService.deleteTypes(types);
	}


	/**
	 *更新文章评论的'是否删除'属性的值
	 * @param articleComment 传递 uuid,isDelete
	 * @return Result.ok()
	 */
	@PostMapping("updateCommentIsDelete")
	public Result updateCommentIsDelete(@RequestBody ArticleComment articleComment) {
		return updateService.updateCommentIsDelete(articleComment);
	}

	/**
	 * 批量更新随想的'是否删除'属性的值
	 * @param articleCommentPayload  载荷类  每个 articleComment 传递 uuid,isDelete
	 * @return Result.ok()
	 */
	@PostMapping("updateCommentsIsDelete")
	public Result updateCommentsIsDelete(@RequestBody ArticleCommentPayload articleCommentPayload) {
		return updateService.updateCommentsIsDelete(articleCommentPayload.getComments());
	}


	/**
	 * 根据uuid跟新TreasureChest的属性
	 * @param treasureChests 传递的参数 (uuid, url,urlName,imageUrl, typeId, description)
	 * @return Result.ok()
	 */
	@PostMapping("updateTreasureChest")
	public Result updateTreasureChest(@RequestBody TreasureChests treasureChests) {
		return updateService.updateTreasureChest(treasureChests);
	}

	/**
	 * 批量彻底删除百宝箱页面友链的信息
	 * @param treasureChests 友链list
	 * @return Result
	 */
	@PostMapping("deleteTreasureChests")
	public Result deleteTreasureChests(@RequestBody TreasureChestsPayload treasureChests) {
		return updateService.deleteTreasureChests(treasureChests.getTreasureChests());
	}


	/**
	 * 更新留言是否显示的值
	 * @param messageList 信息
	 * @return Result
	 */
	@PostMapping("updateMessageListIsDelete")
	public Result updateMessageListIsDelete(@RequestBody MessageList messageList) {
		return updateService.updateMessageListIsDelete(messageList);
	}

	/**
	 * 彻底删除消息
	 * @param messageLists 消息列表
	 * @return Result
	 */
	@PostMapping("deleteMessageLists")
	public Result deleteMessageLists(@RequestBody MessageListPayload messageLists) {
		return updateService.deleteMessageLists(messageLists.getMessageLists());
	}

	/**
	 *  物理删除用户信息
	 * @param users 用户信息集合
	 * @return Result
	 */
	@PostMapping("deleteUsers")
	public Result deleteUsers(@RequestBody UserPayload users) {
		return updateService.deleteUsers(users.getUsers());
	}


	/**
	 * 退回友链申请,即物理删除这些信息
	 * @param treasureChests 申请信息集合
	 * @return Result
	 */
	@PostMapping("refuseTreasureChests")
	public Result refuseTreasureChests(@RequestBody TreasureChestsPayload treasureChests) {
		return updateService.refuseTreasureChests(treasureChests.getTreasureChests());
	}


	/**
	 * 通过友链申请,即将isDelete变为1
	 * @param treasureChests 申请信息集合
	 * @return Result
	 */
	@PostMapping("passTreasureChests")
	public Result passTreasureChests(@RequestBody TreasureChestsPayload treasureChests) {
		return updateService.passTreasureChests(treasureChests.getTreasureChests());
	}


	/**
	 * 更新公告信息(切换显示和不显示):status的值变化 1:显示 0:不显示
	 * @param announcement 提交的公告信息 ( uuid  status)
	 * @return Result
	 */
	@PostMapping("handoffShowAnnouncement")
	public Result handoffShowAnnouncement(@RequestBody Announcement announcement) {
		return updateService.handoffShowAnnouncement(announcement);
	}

	/**
	 * 更新公告信息
	 * @param announcement (uuid,title,message,type,status)
	 * @return  Result
	 */
	@PostMapping("updateAnnouncement")
	public Result updateAnnouncement(@RequestBody Announcement announcement) {
		return updateService.updateAnnouncement(announcement);
	}


}
